-
Notifications
You must be signed in to change notification settings - Fork 77
[ASan][Compiler-rt] Support Gracefull hsa-runtime shutdown. #559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: amd-staging
Are you sure you want to change the base?
[ASan][Compiler-rt] Support Gracefull hsa-runtime shutdown. #559
Conversation
84f2839 to
4e6a327
Compare
4e6a327 to
02dccdb
Compare
fc9cd0d to
b78dbb5
Compare
d41eca8 to
78e3a56
Compare
compiler-rt/lib/sanitizer_common/sanitizer_allocator_amdgpu.cpp
Outdated
Show resolved
Hide resolved
78e3a56 to
e8ae56c
Compare
e8ae56c to
894289b
Compare
894289b to
d9c4492
Compare
Summary:
- Track runtime shutdown via AmdgpuMemFuncs::IsAmdgpuRuntimeShutdown()
and gate further hsa_amd_pointer_info calls.
- Add interception of 'hsa_init' api call.
- Add registration of hsa-runtime associated system events via
'hsa_amd_register_system_event_handler'.
- HSA event registered is 'HSA_AMD_SYSTEM_SHUTDOWN_EVENT'
Summary: - Added wrapper IsAmdgpuRuntimeShutdown for checking state. - Added wrapper NotifyAmdgpuRuntimeShutdown for updating state.
- Add verbose logging logic. - Refactor AmdgpuMemFuncs::Init function. - Add CAS check for AMDGPU shutdown callback registering.
afdf142 to
5fefd6d
Compare
993355c to
5fefd6d
Compare
| void *AmdgpuMemFuncs::Allocate(uptr size, uptr alignment, | ||
| DeviceAllocationInfo *da_info) { | ||
| // Do not allocate if AMDGPU runtime is shutdown | ||
| if (IsAmdgpuRuntimeShutdown()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use UNLIKELY here?
|
|
||
| void AmdgpuMemFuncs::Deallocate(void *p) { | ||
| // Deallocate does nothing after AMDGPU runtime shutdown | ||
| if (IsAmdgpuRuntimeShutdown()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use UNLIKELY here?
|
|
||
| bool AmdgpuMemFuncs::GetPointerInfo(uptr ptr, DevicePointerInfo* ptr_info) { | ||
| // GetPointerInfo returns false after AMDGPU runtime shutdown | ||
| if (IsAmdgpuRuntimeShutdown()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use UNLIKELY here?
| CHECK_LT(idx, n_chunks_); | ||
| h = GetHeader(chunks_[idx], &header); | ||
| CHECK(!dev_runtime_unloaded_); | ||
| if (dev_runtime_unloaded_) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use UNLIKELY here?
| for (uptr i = 0; i < n_chunks_; i++) { | ||
| Header *h = GetHeader(chunks_[i], &header); | ||
| CHECK(!dev_runtime_unloaded_); | ||
| if (dev_runtime_unloaded_) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use UNLIKELY here?
| // Device allocator has dependency on device runtime. If device runtime | ||
| // is unloaded, GetPointerInfo() will fail. For such case, we can still | ||
| // return a valid value for map_beg, map_size will be limited to one page | ||
| if (!dev_runtime_unloaded_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we instead make an UNLIKELY check for unloaded here?
Summary:
and gate further hsa_amd_pointer_info calls.
'hsa_amd_register_system_event_handler'.